
<#include "/shop_common.html"/>

<link href="${basePath}/static/lib/wangEditor/css/normalize.min.css" rel="stylesheet">
<link href="${basePath}/static/lib/wangEditor/css/style.css" rel="stylesheet">
<link href="${basePath}/static/lib/wangEditor/css/layout.css" rel="stylesheet">

<script src="${basePath}/static/lib/wangEditor/js/publishProductEditor.js"></script>

<!-- 编辑器 DOM -->
<div style="border: 1px solid #ccc;">
    <div id="product-description-toolbar" style="border-bottom: 1px solid #ccc;"></div>
    <div id="product-description-content" style="height: 500px"></div>
    <input type="hidden" id="productDescriptionHidden" />
</div>


<script src="${basePath}/static/lib/wangEditor/js/index.min.js"></script>
<script>
    const E = window.wangEditor;

    // 切换语言
    const LANG = location.href.indexOf('lang=en') > 0 ? 'en' : 'zh-CN';
    E.i18nChangeLanguage(LANG);

    window.editor = E.createEditor({
        selector: '#product-description-content',
        html: '<p><br></p>',
        config: {
            placeholder: '请输入...',
            MENU_CONF: {
                uploadImage: {
                    server: basePath+'/api/upload-img',
                    timeout: 5 * 1000,
                    // meta: { token: 'xxx', a: 100 },
                    // metaWithUrl: true, // 参数拼接到 url 上
                    // headers: { Accept: 'text/x-json' },
                    fieldName: 'your-fileName',
                    maxFileSize: 7 * 1024 * 1024, //最大支持7MB
                    base64LimitSize: 1 * 1024 * 1024 // 1M 以下插入 base64
                }
            },
            onChange(editor) {
                // console.log(editor.getHtml())
                document.getElementById("productDescriptionHidden").value=editor.getHtml();
            }
        }
    });

    window.toolbar = E.createToolbar({
        editor,
        selector: '#product-description-toolbar',
        config: {
            excludeKeys: [
                "codeBlock",
                "group-video",
                "insertImage",
                "emotion",
                "insertLink",
                "fullScreen",
                "redo"

            ]
        }
    })
</script>